<template>
  <div class="mui-numbox" data-numbox-min='1' style="height:25px;width:100px;padding:0  30px;">
    <button class="mui-btn mui-btn-numbox-minus" type="button" style="width:30px;">-</button>
    <input id="test" class="mui-input-numbox" type="number" :value="initcount" @change="countChanged" ref="numbox" />
    <button class="mui-btn mui-btn-numbox-plus" type="button"  style="width:30px;">+</button>
  </div>
</template>
<script>
import mui from "../../lib/mui/js/mui.min.js";
export default {
  mounted() {
    // 初始化数字选择框组件
    mui(".mui-numbox").numbox().getValue();
  },
  methods: {
    /* 每当数量值发生改变就把最新的数量同步到购物车的  store中 */
    countChanged() {
      console.log(this.$refs.numbox.value);
      console.log(this.goodsid,77);
      
      this.$store.commit("updateGoodsInfo",{
        id:this.goodsid,
        count:this.$refs.numbox.value
      });
    }
  },

  /* 定义属性  接受父组件传的值 */
  props:['initcount',"goodsid"]
};
</script>
<style lang="less" scoped>
</style>